package com.uni.action;

import com.uni.entity.User;
import com.uni.service.Service;
import com.uni.utils.DruidUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Connection;

/**
 * --------------project-------------
 *
 * @Author Unirithe  - Mr.Chao
 * - CSDN:
 * https://blog.csdn.net/Unirithe
 * - GitHub:
 * https://github.com/unirithe
 * @create 2021/12/29 11:07
 * ------------------------------------------
 */

@WebServlet(name = "UserCheckExistsAction", urlPatterns = "/checkUserExists")
public class UserCheckExistsAction extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username = req.getParameter("username");
        User user = Service.user.queryUserByName(username);
        if(user!=null)
            resp.getWriter().write("false");
        else
            resp.getWriter().write("true");
    }
}
